<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="志愿者审核">
<div class="xm-offline">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="${basepath}/manage/account/toVolunteerCheck">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="detailForm" class="form-horizontal" action="${basepath}/manage/offline/insertJson"
                      method="post">
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            姓名：
                        </label>
                        <div class="controls">
                            <input type="hidden" class="control-text span-width span6" name="id">
                            <input type="text" class="control-text span-width span6" name="nickname"
                                   data-rules="{required : true}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            性别：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span6" name="sex"
                                   data-rules="{required : true}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            手机号：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span6" name=""
                                   data-rules="{required : true}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            编号：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span6" name=""
                                   data-rules="{required : true}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            头像照片：
                        </label>
                        <img src="${basepath}/resource/bui/img/white_sprite-469-300.png"
                             style="height: 100px;width: 100px;margin:0 0 10px 10px">
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            身份证号码：
                        </label>
                        <div class="controls">
                            <input type="text" class="control-text span-width span6" name=""
                                   data-rules="{required : true}"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            身份证照片：
                        </label>
                        <img src="${basepath}/resource/bui/img/white_sprite-469-300.png"
                             style="height: 100px;width: 100px;margin:0 0 10px 10px">
                    </div>
                    <div class="centered">
                        <button type="submit" class="button  button-large  button-success">通过</button>
                        <button type="submit" class="button  button-large  button-success">不通过</button>
                    </div>
                </form>

            </div>
        </div>
    </div>
</div>

<script>
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    var store = new BUI.Data.TreeStore({
        map: {
            name: 'text'
        },
        url: '${basepath}/manage/menu/getMenusByPid?pid=0',
        params: {         //设置请求时的参数
            id: getQueryString("id")
        }
    });

    var form = new BUI.Form.HForm({ //创建表单
        srcNode: '#detailForm',
        submitType: 'ajax'
    }).render();

    form.on('beforesubmit', function (ev) {
        form.ajaxSubmit();
        return false;
    });

    store.on('load', function (ev) {
        var checkedNodes = store.findNodesBy(function (node) {
            if (node.checked == true) {
                return true;
            }
            return false;
        });
        var ids = new Array();
        BUI.each(checkedNodes, function (node) {
            ids.push(node.id);
        });
        form.setFieldValue("privileges", ids.join(','));
    });

    BUI.use('bui/tree', function (Tree) {
        var tree = new Tree.TreeList({
            render: '#t1',
            store: store,
            height: 500,
            showLine: true, //显示连接线
            cascadeCheckd: false, //不级联勾选
            'itemclick': true
        });
        tree.render();
        store.load();
        tree.on('checkedchange', function (ev) {
            var ids = new Array();
            var checkedNodes = tree.getCheckedNodes();
            BUI.each(checkedNodes, function (node) {
                ids.push(node.id);
            });
            form.setFieldValue("privileges", ids.join(','));
        });
    });

    $.ajax({
        type: "POST",
        dataType: "json",
        url: "${basepath}/manage/role/toEditJson",
        data: {
            id: getQueryString("id")
        },
        success: function (data) {
            var form = $("#J_Form")[0];
            BUI.FormHelper.setFields(form, data.data);
        }
    });


</script>



</@page.pageBase>